package pCloud.message;

import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.HashMap;

/**
 * The message containing data from the Proxy to the client.
 * 
 * This is created after the Proxy receives a request from the client. Its
 * content is filled as the reply (ReplyMessage) arrived from the data server
 * 
 */
public class ClientResponse {
	HashMap<InetSocketAddress, ReplyMessage> replies;

	// the same as the corresponding client request Id
	int id;

	// the number of replies needed for the resquest
	int numberOfReplies;

	public ClientResponse(int id, int nr) {
		this.id = id;
		this.numberOfReplies = nr;
		this.replies = new HashMap<InetSocketAddress, ReplyMessage>();
	}

	public HashMap<InetSocketAddress, ReplyMessage> getReplies() {
		return replies;
	}

	public int getId() {
		return id;
	}

	public int getNumberOfReplies() {
		return numberOfReplies;
	}

	public void addReply(InetSocketAddress from, ReplyMessage rm) {
		this.replies.put(from, rm);
		this.numberOfReplies--;
	}
}
